package com.qd.dict.panda;

import com.cdqidi.dict.annotation.FieldBind;
import com.cdqidi.dict.config.IFieldProcess;
import com.qd.common.dict.DictConstant;
import com.qd.common.flow.constant.FlowConstants;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 审批状态转换
 * @author sjk
 */
@Component
@RequiredArgsConstructor
public class ApprovalStatusProcessImpl implements IFieldProcess {
    @Override
    public String processName() {
        return DictConstant.APPROVAL_STATUS;
    }

    @Override
    public Object convertValue(FieldBind fieldBind, Object fieldValue) {
        if (null == fieldValue) {
            return "";
        }
        int value = Integer.parseInt(fieldValue.toString());
        if (value == FlowConstants.APPROVAL_STATUS_0) {
            return "未审核";
        }
        if (value == FlowConstants.APPROVAL_STATUS_1) {
            return "审核通过";
        }
        if (value == FlowConstants.APPROVAL_STATUS_2) {
            return "审核未通过";
        }
        if (value == FlowConstants.APPROVAL_STATUS_3) {
            return "终结";
        }
        return "";
    }
}